package com.hyg.base.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.hyg.base.R;

/**
 * FileName: ProgressDialog
 * Author: huangyuguang
 * Date: 2022/6/21
 * Description: 进度条弹窗
 */
public class ProgressDialog extends Dialog {

    private TextView tvTitle;
    private TextView tvContent;
    private TextView tvProgress;
    private ProgressBar progressBar;

    private String title;
    private String content;

    public ProgressDialog(@NonNull Context context , String title, String content) {
        super(context, R.style.ActionMiddleDialogStyle);
        this.title = title;
        this.content = content;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.base_dialog_progress);
        setCancelable(false);
        setCanceledOnTouchOutside(false);

        tvTitle = findViewById(R.id.tv_title);
        tvContent = findViewById(R.id.tv_content);
        tvProgress = findViewById(R.id.tv_progress);
        progressBar = findViewById(R.id.progressBar);

        tvTitle.setText(title);
        tvContent.setText(content);
    }

    /**
     * max = 100，0 <= progress < = 100
     * @param progress
     */
    public void updateProgress(int progress){
        progressBar.setProgress(progress);
        tvProgress.setText(progress + "%");
    }
}
